package com.pet.server.ext.action.user;

import java.awt.print.PageFormat;
import java.util.List;

import net.sf.json.JSONArray;

import com.pet.server.ext.ActionBase;
import com.pet.server.ext.ApiError;
import com.pet.server.ext.BeanToJson;
import com.pet.server.ext.Result;
import com.pet.server.ext.constants.BaseAttribute;
import com.pet.server.ext.data.Image;
import com.pet.server.ext.data.Page;
import com.pet.server.ext.data.PetMissing;
import com.pet.server.ext.service.UserService;
import com.pet.server.ext.util.JsonUtil;
import com.pet.server.ext.util.Parameters;

public class Missinglist extends ActionBase{
	public String queryString;
	public Missinglist(){
		 needCheckAuth =true;
	}
	
	@Override
	public void initParameters(Parameters params) throws ApiError {	
		parseToParameter(params);
		
	}
	
	@Override
	public Result invokeService() throws ApiError {
		UserService userService = new UserService();
		List<PetMissing> list = userService.queryPetMissing(user.user_id);
		for(PetMissing pm:list){
            List<Image> l = userService.queryImage(pm.miss_id, BaseAttribute.image_type.pet_missing.toString());
            if(l.size()>0){
            	pm.image=l.get(0).src;
            }
		}
		Result result = new Result();
        result.put("data", JsonUtil.missingToJsonArray(list));
	    return result;
	}


}
